<template>
  <div class="not-found-container">
    <!-- 背景装饰 -->
    <div class="background-decoration">
      <div class="decoration-circle circle-1"></div>
      <div class="decoration-circle circle-2"></div>
      <div class="decoration-circle circle-3"></div>
      <div class="decoration-triangle triangle-1"></div>
      <div class="decoration-triangle triangle-2"></div>
    </div>

    <!-- 主要内容 -->
    <div class="content-wrapper">
      <!-- 404数字 -->
      <div class="error-code">
        <span class="digit four">4</span>
        <div class="zero-container">
          <span class="digit zero">0</span>
          <div class="zero-content">
            <i class="el-icon-warning-outline"></i>
          </div>
        </div>
        <span class="digit four">4</span>
      </div>

      <!-- 错误信息 -->
      <div class="error-info">
        <h1 class="error-title">页面未找到</h1>
        <p class="error-description">
          抱歉，您访问的页面不存在或已被移除。<br>
          请检查URL是否正确，或通过以下方式继续浏览。
        </p>
      </div>

      <!-- 建议链接 -->
      <div class="suggestion-links">
        <div class="suggestion-card" @click="goHome">
          <div class="card-icon">
            <i class="el-icon-house"></i>
          </div>
          <div class="card-content">
            <h3>返回首页</h3>
            <p>回到系统主页</p>
          </div>
        </div>

        <div class="suggestion-card" @click="goBack">
          <div class="card-icon">
            <i class="el-icon-back"></i>
          </div>
          <div class="card-content">
            <h3>返回上页</h3>
            <p>回到之前的页面</p>
          </div>
        </div>

        <div class="suggestion-card" @click="refreshPage">
          <div class="card-icon">
            <i class="el-icon-refresh"></i>
          </div>
          <div class="card-content">
            <h3>刷新页面</h3>
            <p>重新加载当前页面</p>
          </div>
        </div>
      </div>

      <!-- 快速导航 -->
      <div class="quick-nav">
        <h3>快速导航</h3>
        <div class="nav-links">
          <router-link to="/total" class="nav-link">
            <i class="el-icon-menu"></i>
            总览页面
          </router-link>
          <router-link to="/login" class="nav-link">
            <i class="el-icon-user"></i>
            用户登录
          </router-link>
        </div>
      </div>

      <!-- 搜索框 -->
      <div class="search-section">
        <el-input
          v-model="searchKeyword"
          placeholder="搜索您想要的内容..."
          class="search-input"
          @keyup.enter="handleSearch">
          <template #append>
            <el-button icon="el-icon-search" @click="handleSearch"></el-button>
          </template>
        </el-input>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

export default {
  name: 'NotFound',
  setup() {
    const router = useRouter()
    const searchKeyword = ref('')

    // 返回首页
    const goHome = () => {
      router.push('/total')
    }

    // 返回上一页
    const goBack = () => {
      router.go(-1)
    }

    // 刷新页面
    const refreshPage = () => {
      window.location.reload()
    }

    // 搜索功能
    const handleSearch = () => {
      if (searchKeyword.value.trim()) {
        // 这里可以实现搜索逻辑
        // 搜索功能实现
        // 暂时跳转到总览页面
        router.push('/total')
      }
    }

    return {
      searchKeyword,
      goHome,
      goBack,
      refreshPage,
      handleSearch
    }
  }
}
</script>

<style scoped>
/* 主容器 */
.not-found-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 背景装饰 */
.background-decoration {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.decoration-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.1;
  animation: float 6s ease-in-out infinite;
}

.circle-1 {
  width: 300px;
  height: 300px;
  background: white;
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.circle-2 {
  width: 200px;
  height: 200px;
  background: white;
  top: 60%;
  right: 15%;
  animation-delay: 2s;
}

.circle-3 {
  width: 150px;
  height: 150px;
  background: white;
  bottom: 20%;
  left: 20%;
  animation-delay: 4s;
}

.decoration-triangle {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0.1;
  animation: rotate 10s linear infinite;
}

.triangle-1 {
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  border-bottom: 100px solid white;
  top: 20%;
  right: 20%;
  animation-delay: 1s;
}

.triangle-2 {
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-bottom: 70px solid white;
  bottom: 30%;
  left: 15%;
  animation-delay: 3s;
}

/* 内容包装器 */
.content-wrapper {
  text-align: center;
  z-index: 10;
  padding: 20px;
  max-width: 800px;
  width: 100%;
}

/* 错误代码 */
.error-code {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
  gap: 10px;
}

.digit {
  font-size: 160px;
  font-weight: bold;
  color: white;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  line-height: 1;
  animation: pulse 2s ease-in-out infinite alternate;
}

.four {
  color: rgba(255, 255, 255, 0.9);
}

.zero-container {
  position: relative;
  display: inline-block;
}

.zero {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.8);
}

.zero-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 60px;
  color: #ff6b6b;
  z-index: 2;
}

/* 错误信息 */
.error-info {
  margin-bottom: 50px;
}

.error-title {
  font-size: 36px;
  font-weight: bold;
  color: white;
  margin-bottom: 20px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.error-description {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
  margin-bottom: 30px;
}

/* 建议链接 */
.suggestion-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.suggestion-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 15px;
}

.suggestion-card:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.card-icon {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.card-content h3 {
  color: white;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 5px;
}

.card-content p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  margin: 0;
}

/* 快速导航 */
.quick-nav {
  margin-bottom: 30px;
}

.quick-nav h3 {
  color: white;
  font-size: 20px;
  margin-bottom: 15px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.nav-link {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 14px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* 搜索区域 */
.search-section {
  max-width: 500px;
  margin: 0 auto;
}

.search-input {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-input :deep(.el-input__inner) {
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
}

.search-input :deep(.el-input__inner::placeholder) {
  color: rgba(255, 255, 255, 0.6);
}

.search-input :deep(.el-input-group__append) {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
}

.search-input :deep(.el-button) {
  background: transparent;
  border: none;
  color: white;
}

/* 动画效果 */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.05);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .error-code {
    flex-direction: column;
    gap: 0;
  }

  .digit {
    font-size: 100px;
  }

  .error-title {
    font-size: 28px;
  }

  .error-description {
    font-size: 16px;
  }

  .suggestion-links {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .nav-links {
    flex-direction: column;
    align-items: center;
  }

  .nav-link {
    width: 100%;
    max-width: 200px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .digit {
    font-size: 80px;
  }

  .zero-content {
    font-size: 40px;
  }

  .suggestion-card {
    padding: 15px;
  }

  .card-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}
</style>